package com.vortex.cloud.zhsw.xinyang.converter;

import com.github.liaochong.myexcel.core.container.Pair;
import com.github.liaochong.myexcel.core.converter.ConvertContext;
import com.github.liaochong.myexcel.core.converter.WriteConverter;
import com.vortex.cloud.zhsw.xinyang.dto.DictDataDTO;

import java.lang.reflect.Field;

/**
 * @author huohao@vortexinfo.cn
 * @date 2022/3/22 11:02
 */
public class DictDataWriterConverter implements WriteConverter {
    @Override
    public Pair<Class, Object> convert(Field field, Class<?> fieldType, Object fieldVal, ConvertContext convertContext) {
        DictDataDTO dictData = (DictDataDTO) fieldVal;
        return Pair.of(String.class, dictData.getValue());
    }

    @Override
    public boolean support(Field field, Class<?> fieldType, Object fieldVal, ConvertContext convertContext) {
        return fieldType == DictDataDTO.class;
    }
}
